<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="white" />
		<meta name="format-detection" content="telephone=no" />
		<!--Iphpone电话号码串识别 -->
		<meta http-equiv="x-rim-auto-match" content="none" />
		<!--电话号码串识别 -->
		<title>拨云见日科技</title>
		<link rel="SHORTCUT ICON" href="/static/favicon.ico" type="image/x-icon"/>
		<script src='/static/js/jquery.js' type='text/javascript'></script>
		<script src='/static/js/qrcode.js' type='text/javascript'></script>
		<script src='/static/js/layui.js' type='text/javascript'></script>
		<link href="/static/css/index.css" rel="stylesheet" type="text/css" />
		<link href="/static/css/layui.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		{% include "base.html" %}
		<div class="wrapper">
			<!--功能二维码-->
			<div class="wrapper_cont">
				<div class="duty">请选择供应商</div>
				{% include "right.html" %}
				<div class="layui-card-body">
					<div class="layui-row layui-col-space15" id="ls">

				  	</div>
				</div>
			</div>
		</div>
	</body>
	<script type='text/javascript'>
		var param = "{{getSession('robot_id')}}"
		$(function(){
			document.getElementById("v").value="";
			loadData();
			getValue();
		})

		function loadData(){
			var action = $("#mm").attr("action")
			$.post(action,{sql:"select rp.id,rp.display_name from res_partner rp INNER join purchase_order pr on rp.id = pr.partner_id " +
								"where state = 'purchase' order by date_planned limit 20"},function(result){
				result = JSON.parse(result);
				var rs=[]
				for(v in result){
					var id = "li_"+result[v][0]
					var len = $("#"+id).length;
					if(len>0){
						continue;
					}
					rs.push(result[v]);
					$("#ls").append("<div class='layui-panel barcode' style='width:120px'><div id='"+id+"'></div><div style='float:left;width:120px;font-size: 10px;line-height: 12px;height:25px;'>"+result[v][1]+"</div></div>")
				}

				for(v in rs){
					var id = "li_"+rs[v][0]
					new QRCode(document.getElementById(id), {
						text: "0"+rs[v][0],
						colorDark: '#000000',
						colorLight: '#ffffff',
						width:150,
						height:150,
						correctLevel: QRCode.CorrectLevel.H
					});
				}
			});
		}

		function getValue(){
			v = document.getElementById('v').value;
			if(!v){
				$("#v").focus();
				setTimeout(getValue,1000);
				return
			}
			if(commFun(v,param)){
		    	return;
			}
			if(v.startsWith("P")){
				setSession("orderid",v);
				setTimeout(function(){
					location.href = "index.html?data="+param
				},1000);
				return;
			}
			if(v.startsWith("A")){
				setSession("asncode",v);
				setTimeout(function(){
					location.href = "index.html?data="+param
				},1000);
				return;
			}
			if(v.startsWith("WH")){
				setSession("revname",v);
				setTimeout(function(){
					location.href = "index.html?data="+param
				},1000);
				return;
			}
			var id = "li_"+v
			if($("#"+id).length==0){
				document.getElementById('v').value = "";
				layer.msg("无效供应商")
				setTimeout(getValue, 1000);
				return;
			}
			document.getElementById('v').value = "";
			setTimeout(function(){
				location.href = "orderList.html?data="+v
			},1000);
		}
	</script>
	{% include "footer.html" %}
</html>
